package com.derbysoft.dswitch.adapter.ihg.dswitch2.service.handler;

import com.derbysoft.dswitch.adapter.ihg.common.domain.OperationType;
import com.derbysoft.dswitch.adapter.ihg.common.domain.ReservationLog;
import com.derbysoft.dswitch.adapter.ihg.dswitch2.service.impl.ReservationIDUtils;
import com.derbysoft.remote.dswitch.core.GenericRQ;
import com.derbysoft.remote.dswitch.hotel.dto.HotelReservationRQ;

import java.util.UUID;

/**
 * Created by: jason
 * Date: 2012-09-07
 */
public class HotelModifyReservationHandler extends HotelPreviewHandler {
    @Override
    protected ReservationLog createReservationLog(GenericRQ<HotelReservationRQ> request) {
        ReservationLog reservationLog = new ReservationLog();
        reservationLog.setId(UUID.randomUUID().toString());
        reservationLog.setTaskId(request.getHeader().getTaskId());
        reservationLog.setChannel(request.getHeader().getSource().getUniqueID().getId());
        reservationLog.setErsp(ReservationIDUtils.getErspNo(request.getPayload().getHotelReservationIDs()).getResIDValue());
        reservationLog.setHotels(request.getPayload().getHotelReservation().getHotelRef().getCode());
        reservationLog.setOperationType(OperationType.HOTEL_MODIFY_RESERVATION);
        return reservationLog;
    }
}
